<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="error.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:useBean class="add.Main_add" id="mai" scope="request" />
<jsp:useBean class="add.Detail_add" id="det" scope="request" />
<jsp:useBean class="show.Main_show" id="shw" scope="request" />
</head>

<body>
<% 
       request.setCharacterEncoding("utf-8");
	   int cou = 0;
	   String name = request.getParameter("name");
	   String pass = request.getParameter("pass");
	   String qq = request.getParameter("qq");
	   String mail = request.getParameter("mail");
	   String local = request.getParameter("local");
	   String sex = request.getParameter("sex");
	   String birth = request.getParameter("birth");
	   java.sql.Date bir = new java.sql.Date(Integer.parseInt(birth.split("/")[2])-1900,Integer.parseInt(birth.split("/")[0])-1,Integer.parseInt(birth.split("/")[1]));
	   
	   String tel = request.getParameter("tel");
	   int id = 0;
	   id = shw.getID().getLast()+1;
	   
	   String pa = request.getParameter("pa");
	   String ma = request.getParameter("ma");
	   String food = request.getParameter("food");
	   String pri = request.getParameter("pri");
	   String mid = request.getParameter("mid");
	   String hig = request.getParameter("hig");
	   cou = mai.add(id,name,pass,qq,tel,mail,local,sex,bir);
	   det.add(ma,pa,pri,mid,hig,food,name,id);
	   if(cou==0)
	   {
	          out.print("<script>alert('信息已录入，无须重复！');</script>");
			  out.print("页面跳转至首页......");
			  out.print("<script>window.location='../index.jsp';</script>");
	   }
	   else
	   {
	          out.print("恭喜注册成功<br /><a href='../login.jsp'>登陆</a>?或者随便逛逛？");
	   }
%>
</body>
</html>
